<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .clearfix:after {
        /*伪元素是行内元素 正常浏览器清除浮动方法*/
        content: "";
        display: block;
        clear: both;
        height: 0; /*解决浏览器兼容问题*/
        visibility: hidden; /*解决浏览器兼容问题*/
      }
      .clearfix {
        *zoom: 1; /*ie6清除浮动的方式 *号只有IE6-IE7执行，其他浏览器不执行*/
      }
      .box {
        width: 400px;
        /* height: 200px; */
        border: 1px solid red;
        margin: 50px auto;
        /* 方案1： 解决父容器高度为0 */
        /* overflow: hidden; */
      }

      .item {
        width: 100px;
        height: 100px;
      }

      .item1 {
        background-color: orange;
        float: left;
      }

      .item2 {
        background-color: skyblue;
        float: right;
      }
    </style>
  </head>
  <body>
    <div class="box clearfix">
      <div class="item item1"></div>
      <div class="item item2"></div>
    </div>
  </body>
</html>
